import streamlit as st
import requests

st.set_page_config(page_title='知影', page_icon='clapper', layout="wide", initial_sidebar_state='auto',
                   menu_items={'About': '# This is a header. This is an *extremely* cool app!'})


def display_profile():
    if "username" not in st.session_state:
        st.warning("请先登录")
        return

    st.title(f"{st.session_state['username']}的个人信息")

    # 显示用户信息
    st.markdown(f"**用户名：** {st.session_state['username']}")
    st.markdown(f"**用ID：** {st.session_state['user_id']}")
    # 添加更多用户信息...

    st.divider()

    # # 获取并显示会话记录 # TODO: 解决历史会话404
    # response = requests.get('http://localhost:8000/conversations', headers=st.session_state["headers"])
    # if response.status_code == 200:
    #     conversations = response.json()
    #     for i, conversation in enumerate(conversations):
    #         st.subheader(f"会话{i + 1}")
    #         cols = st.beta_columns(2)
    #         for j, message in enumerate(conversation["messages"]):
    #             with cols[j % 2]:
    #                 st.markdown(f"**{message['role']}：** {message['content']}")
    #             st.session_state["messages"].append({"role": message['role'], "content": message['content']})
    #             with st.chat_message(message["role"], avatar='📽️' if message["role"] == "ai" else '😍'):
    #                 st.write(message["content"])
    # # TODO: 添加会话记录的分页功能
    # else:
    #     st.error("获取会话记录失败")
    #
    # st.divider()

    # TODO: 偏好数据分析图表


if __name__ == "__main__":
    display_profile()
